package com.sunda.spmsweb.wmscontroller;


import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmswms.service.ICostCenterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 仓库信息表 前端控制器
 * </p>
 *
 * @author Wayne
 * @since 2020-11-24
 */
@RestController
@RequestMapping("/costCenter")
@Api(tags = "成本中心信息", description = "成本中心信息接口")
public class CostCenterController {

    @Autowired
    ICostCenterService iCostCenterService;

    @RequestMapping("/getCostCenterList")
    @ApiOperation(value = "获取全部成本中心信息",notes = "获取全部成本中心信息", httpMethod = "GET")
    public ResponseResult getCostCenterList(){
        try {
            return ResponseResult.success().add("costCenterList", iCostCenterService.getCostCenterList());
        }catch (Exception e){
            e.printStackTrace();
            return ResponseResult.error("获取成本中心信息出错");
        }
    }

    @RequestMapping("/getCostCenterByWerks")
    @ApiOperation(value = "根据工厂获取成本中心信息", notes = "根据工厂获取成本中心信息 \n" +
            "werks = GF02 \n", httpMethod = "GET")
    public ResponseResult getCostCenterByWerks(@RequestParam String werks) {
        try {
            return ResponseResult.success().add("costCenterList", iCostCenterService.getCostCenterByWerks(werks));
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseResult.error("获取成本中心失败");
        }
    }

}
